/**
 * 统计图表
 * */

var tabThs = [
    '', '个人', '项目组', '所有项目', '同比环比', 
];
var tabLinks = [
    '', 'person', 'item', 'all', 'huan', 'tu',
];
var tabTds = [
    '', '个人工时汇总', '项目组工时汇总', '所有项目工时汇总', '同比环比数据比较', 
];


//tab
function tabHtml(){
    var uinfo = getUserInfo();
    console.log(uinfo);
    if (uinfo.role_id == 4 && uinfo.is_leader == 0) {
        tabThs = [tabThs[0], tabThs[1]];
        tabTds = [tabTds[0], tabTds[1]];
        tabLinks = [tabLinks[0], tabLinks[1]];
    }
    else if (uinfo.role_id < 4 || uinfo.is_leader > 0) {
        tabThs = [tabThs[0], tabThs[1], tabThs[2]];
        tabTds = [tabTds[0], tabTds[1], tabTds[2]];
        tabLinks = [tabLinks[0], tabLinks[1], tabLinks[2]];
    }
    console.log(uinfo.is_leader, tabThs);
    var h = '', i, d = tabThs;
    for (i = 1; i < d.length; i ++) {
        if (i == tl) {
            h += '<span class="tli hover" onclick="toTab(' + i + ');">' + d[i] + '</span>';
        } else {
            h += '<span class="tli" onclick="toTab(' + i + ');">' + d[i] + '</span>';
        }
    }
    $('.tab').html(h);
    $('.title').html('统计-' + tabTds[tl]);
}

function toTab(v){
    var tt = '';
    for (var i = 1; i <= tabLinks.length; i ++) {
        if (i == v) {
            tt = tabLinks[i];
        }
    }
    console.log(tt);
    if (tt == '') {
        msgPop({msg: 'error'}); return
    }
    window.location.href = tt + '.html';
}